<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="/pages/template/byme/template1.xhtml">
	<ui:define name="title">User page</ui:define>
	<ui:define name="content">
		<h:form id="form">
			<p:messages id="messages" showSummary="true" />
			<p:dataTable value="#{manageUsers.usersDataModel}"
				selection="#{manageUsers.selectedUsers}" var="user" paginator="true"
				rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" widgetVar="usersTable"
				emptyMessage="No user found with given criterial">
				<f:facet name="header">
			    Users Table for MultiSelect
			</f:facet>
				<p:ajax event="rowEdit" listener="#{manageUsers.onEdit}"
					update=":form:messages" />
				<p:column selectionMode="multiple" style="width:18px" />
				<!-- FilterMatchMode co the la contains, exact,startsWith,endsWith -->
				<p:column headerText="No" style="text-align:center">
			#{manageUsers.usersDataModel.rowIndex+1}
			</p:column>
				<p:column sortBy="#{user.username}" filterBy="#{user.username}"
					filterMatchMode="contains" headerText="Username">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{user.username}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{user.username}"
								validatorMessage="Row #{manageUsers.usersDataModel.rowIndex+1}:length of username must be from 5 to 12">
								<f:validateRegex pattern="^\w{5,12}$" />
							</p:inputText>
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="Password">
					<h:outputText value="#{user.password}" />
				</p:column>
				<p:column headerText="Enabled">
					<p:selectBooleanCheckbox value="#{user.enabled}" />
				</p:column>
				<p:column headerText="Options" style="width:50px">
					<p:rowEditor />
				</p:column>
				<f:facet name="footer">
					<p:commandButton id="multiViewButton" value="View"
						icon="ui-icon-search" update=":form:displayMulti"
						oncomplete="multiUserDialog.show()" />  Number of Users: #{manageUsers.users.size()}
				</f:facet>
			</p:dataTable>
			<p:dialog id="multiDialog" header="Users Detail"
				widgetVar="multiUserDialog" height="300" showEffect="fade"
				hideEffect="explode">

				<p:dataList id="displayMulti" value="#{manageUsers.selectedUsers}"
					var="selectedUser">
            Username: #{selectedUser.username}, Year: #{selectedUser.password}
       		</p:dataList>
			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>
</html>
